package com.gpb.common.dao;

import java.util.List;

import org.mybatis.spring.support.SqlSessionDaoSupport;

import com.gpb.common.page.Pagination;


/**
 * MybatisDao
 * @author Poppy Kwoks
 * @dateTime May 11, 2014  9:28:26 AM
 */
public class MybatisDao  extends SqlSessionDaoSupport {
	public Integer save(String key,Object obj){
		return getSqlSession().insert(key, obj);
	}
	public Integer delete(String key,Object obj){
		return getSqlSession().delete(key, obj);
	}
	public Integer update(String key,Object obj){
		return getSqlSession().update(key, obj);
	}
	@SuppressWarnings("unchecked")
	public <T> T get(String key,T t){
		return (T)getSqlSession().selectOne(key,t);
	}
	@SuppressWarnings("unchecked")
	public <T> List<T> getList(String key,T t,Pagination page){
		page.setList(getSqlSession().selectList(key,t,page));
		return page.getList();
	}
}
